// MESSAGE ATTITUDE_BODY_DEBUG support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief ATTITUDE_BODY_DEBUG message
 *
 * ATTITUDE_BODY_DEBUG
 */
struct ATTITUDE_BODY_DEBUG : mavlink::Message {
    static constexpr msgid_t MSG_ID = 21;
    static constexpr size_t LENGTH = 112;
    static constexpr size_t MIN_LENGTH = 112;
    static constexpr uint8_t CRC_EXTRA = 196;
    static constexpr auto NAME = "ATTITUDE_BODY_DEBUG";


    float roll_pre; /*<  roll prediction. */
    float pitch_pre; /*<  pitch prediction. */
    float yaw_pre; /*<  yaw prediction. */
    float roll_obs; /*<  roll observe. */
    float pitch_obs; /*<  pitch observe. */
    float yaw_obs_mag; /*<  yaw magnet observe. */
    float yaw_obs_rtk; /*<  yaw rtk observe. */
    float roll_obs_sub_pred; /*<  roll observe deviation. */
    float pitch_obs_sub_pred; /*<  roll observe deviation. */
    float yaw_obs_sub_pred; /*<  roll observe deviation. */
    float ba_x_pre; /*<  x predicte acceleration . */
    float ba_y_pre; /*<  y predicte acceleration . */
    float ba_z_pre; /*<  z predicte acceleration . */
    float ba_x_obs; /*<  x observe acceleration . */
    float ba_y_obs; /*<  y observe acceleration . */
    float ba_z_obs; /*<  z observe acceleration . */
    float bm_x_pre; /*<  x predicte magnet . */
    float bm_y_pre; /*<  y predicte magnet . */
    float bm_z_pre; /*<  z predicte magnet . */
    float bm_x_obs; /*<  x observe magnet . */
    float bm_y_obs; /*<  y observe magnet . */
    float bm_z_obs; /*<  z observe magnet . */
    float bw_norm; /*<  angle speed norm . */
    float ba_norm; /*<  acceleration norm . */
    float bm_norm; /*<  magnet norm . */
    uint32_t time_used; /*<  used time. */
    uint32_t static_state; /*<  static state. */
    uint32_t disturb_state; /*<  disturb state. */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  roll_pre: " << roll_pre << std::endl;
        ss << "  pitch_pre: " << pitch_pre << std::endl;
        ss << "  yaw_pre: " << yaw_pre << std::endl;
        ss << "  roll_obs: " << roll_obs << std::endl;
        ss << "  pitch_obs: " << pitch_obs << std::endl;
        ss << "  yaw_obs_mag: " << yaw_obs_mag << std::endl;
        ss << "  yaw_obs_rtk: " << yaw_obs_rtk << std::endl;
        ss << "  roll_obs_sub_pred: " << roll_obs_sub_pred << std::endl;
        ss << "  pitch_obs_sub_pred: " << pitch_obs_sub_pred << std::endl;
        ss << "  yaw_obs_sub_pred: " << yaw_obs_sub_pred << std::endl;
        ss << "  ba_x_pre: " << ba_x_pre << std::endl;
        ss << "  ba_y_pre: " << ba_y_pre << std::endl;
        ss << "  ba_z_pre: " << ba_z_pre << std::endl;
        ss << "  ba_x_obs: " << ba_x_obs << std::endl;
        ss << "  ba_y_obs: " << ba_y_obs << std::endl;
        ss << "  ba_z_obs: " << ba_z_obs << std::endl;
        ss << "  bm_x_pre: " << bm_x_pre << std::endl;
        ss << "  bm_y_pre: " << bm_y_pre << std::endl;
        ss << "  bm_z_pre: " << bm_z_pre << std::endl;
        ss << "  bm_x_obs: " << bm_x_obs << std::endl;
        ss << "  bm_y_obs: " << bm_y_obs << std::endl;
        ss << "  bm_z_obs: " << bm_z_obs << std::endl;
        ss << "  bw_norm: " << bw_norm << std::endl;
        ss << "  ba_norm: " << ba_norm << std::endl;
        ss << "  bm_norm: " << bm_norm << std::endl;
        ss << "  time_used: " << time_used << std::endl;
        ss << "  static_state: " << static_state << std::endl;
        ss << "  disturb_state: " << disturb_state << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << roll_pre;                      // offset: 0
        map << pitch_pre;                     // offset: 4
        map << yaw_pre;                       // offset: 8
        map << roll_obs;                      // offset: 12
        map << pitch_obs;                     // offset: 16
        map << yaw_obs_mag;                   // offset: 20
        map << yaw_obs_rtk;                   // offset: 24
        map << roll_obs_sub_pred;             // offset: 28
        map << pitch_obs_sub_pred;            // offset: 32
        map << yaw_obs_sub_pred;              // offset: 36
        map << ba_x_pre;                      // offset: 40
        map << ba_y_pre;                      // offset: 44
        map << ba_z_pre;                      // offset: 48
        map << ba_x_obs;                      // offset: 52
        map << ba_y_obs;                      // offset: 56
        map << ba_z_obs;                      // offset: 60
        map << bm_x_pre;                      // offset: 64
        map << bm_y_pre;                      // offset: 68
        map << bm_z_pre;                      // offset: 72
        map << bm_x_obs;                      // offset: 76
        map << bm_y_obs;                      // offset: 80
        map << bm_z_obs;                      // offset: 84
        map << bw_norm;                       // offset: 88
        map << ba_norm;                       // offset: 92
        map << bm_norm;                       // offset: 96
        map << time_used;                     // offset: 100
        map << static_state;                  // offset: 104
        map << disturb_state;                 // offset: 108
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> roll_pre;                      // offset: 0
        map >> pitch_pre;                     // offset: 4
        map >> yaw_pre;                       // offset: 8
        map >> roll_obs;                      // offset: 12
        map >> pitch_obs;                     // offset: 16
        map >> yaw_obs_mag;                   // offset: 20
        map >> yaw_obs_rtk;                   // offset: 24
        map >> roll_obs_sub_pred;             // offset: 28
        map >> pitch_obs_sub_pred;            // offset: 32
        map >> yaw_obs_sub_pred;              // offset: 36
        map >> ba_x_pre;                      // offset: 40
        map >> ba_y_pre;                      // offset: 44
        map >> ba_z_pre;                      // offset: 48
        map >> ba_x_obs;                      // offset: 52
        map >> ba_y_obs;                      // offset: 56
        map >> ba_z_obs;                      // offset: 60
        map >> bm_x_pre;                      // offset: 64
        map >> bm_y_pre;                      // offset: 68
        map >> bm_z_pre;                      // offset: 72
        map >> bm_x_obs;                      // offset: 76
        map >> bm_y_obs;                      // offset: 80
        map >> bm_z_obs;                      // offset: 84
        map >> bw_norm;                       // offset: 88
        map >> ba_norm;                       // offset: 92
        map >> bm_norm;                       // offset: 96
        map >> time_used;                     // offset: 100
        map >> static_state;                  // offset: 104
        map >> disturb_state;                 // offset: 108
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
